package com.example.javafx.simple;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.DatePicker;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.time.LocalDate;

public class DatePickerExample extends Application {

    @Override
    public void start(Stage primaryStage) {
        // 创建 DatePicker
        DatePicker datePicker = new DatePicker();
        
        // 设置日期选择事件处理器
        datePicker.setOnAction(e -> {
            LocalDate selectedDate = datePicker.getValue();
            System.out.println("Selected Date: " + selectedDate);
        });

        // 创建布局并添加 DatePicker
        VBox root = new VBox(datePicker);
        Scene scene = new Scene(root, 300, 200);
        
        primaryStage.setTitle("DatePicker Example");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}